package com.xuecheng.client.sdk.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author 程序员小魏
 * @create 2023-11-07 12:21
 * 状态码枚举类
 */
public enum CodeEnums {


    REQ_PARAM_ERROR("40000","请求参数错误"),

    REQ_ERROR("50000","服务器内部错误，请求失败");

    private final String code;

    private final String desc;

    private static final Map<String,CodeEnums> MAP = new HashMap<>(Arrays.stream(values()).collect(Collectors.toMap(CodeEnums::getCode, Function.identity())));

    CodeEnums(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static CodeEnums codeValueOf(String code){
        return MAP.get(code);
    }


}
